﻿@model Unijovem.UI.Models.ArquivoModel
           
<script type="text/javascript">
    $(document).ready(function () {
        $("#@string.Concat("Titulo", Model.Id)").blur(function () {

            $.ajax({ type: "POST",
                url: "/Arquivo/SalvarTitulo",
                data: "titulo=" + $("#@string.Concat("Titulo", Model.Id)").val() + "&id=" + $("#@string.Concat("Id", Model.Id)").val() + "&idExterno=" + $("#@string.Concat("IdExterno", Model.Id)").val(),
                success: function (result) {
                    if (result.success)
                        $("#@string.Concat("SalvoTitulo", Model.Id)").show();
                },
                error: function (req, status, error) {
                    alert("Sorry! We could not receive your feedback at this time.");
                }
            });
        });

         $("#@string.Concat("Descricao", Model.Id)").blur(function () {

            $.ajax({ type: "POST",
                url: "/Arquivo/SalvarDescricao",
                data: "Descricao=" + $("#@string.Concat("Descricao", Model.Id)").val() + "&id=" + $("#@string.Concat("Id", Model.Id)").val() + "&idExterno=" + $("#@string.Concat("IdExterno", Model.Id)").val(),
                success: function (result) {
                    if (result.success)
                        $("#@string.Concat("SalvoDescricao", Model.Id)").show();
                },
                error: function (req, status, error) {
                    alert("Sorry! We could not receive your feedback at this time.");
                }
            });
        });
    });
</script>

@using (Html.BeginForm("Editar", "Arquivo"))
{
    @Html.ValidationSummary(true)
    
    <tr>
        <td>
            <div class="editor-label">
                @Html.LabelFor(model => model.Titulo)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(model => model.Titulo, new { id = "Titulo" + Model.Id })
            </div>
            <span id="@string.Concat("SalvoTitulo",Model.Id)" style="display:none;">Salvo</span>
        </td>
        <td>
            <div class="editor-label">
                @Html.LabelFor(model => model.Descricao)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(model => model.Descricao, new { id = "Descricao" + Model.Id })
            </div>
            <span id="@string.Concat("SalvoDescricao",Model.Id)" style="display:none;">Salvo</span>
        </td>
        <td>
            <img height="150px" alt="@Model.Titulo" 
                src="@Url.Content(System.IO.Path.Combine(Unijovem.UI.Models.ArquivoModel.SelecionarCaminhoImagem(Unijovem.UI.Models.ArquivoModel.TipoArquivo.Evento), String.IsNullOrEmpty(Model.Nome) ? string.Empty : Model.Nome))" />
        </td>
        <td>
            @*.bmp;.gif;.jpg;.jpeg;.jpg2;.jp2;.pict;.png;.tiff;.tif*@
            @Html.HiddenFor(model => model.Id, new { id = "Id" + Model.Id })    
            @Html.HiddenFor(model => model.IdExterno, new { id = "IdExterno" + Model.Id })
            @Html.HiddenFor(model => model.Nome)
            @*<input type="submit" value="Save" />*@
        </td>
    </tr>
}
